<?php use_stylesheet('forms.css') //load css pf order page   ?>
<?php use_stylesheet('hoverTables.css') //load css of tables  ?>
<div id="nav"><!-- Navigation with tabs -->
    <ul>
        <a href="<?php echo url_for('sales_index_contacts') ?>"><li class="no_sel"><?php echo image_tag('Icons/ic_menu_contacts.png') ?>Contacts</li></a>
        <a href="<?php echo url_for('sales_index_orders') ?>"><li class="no_sel"><?php echo image_tag('Icons/ic_menu_orders.png') ?>Orders</li></a>
        <a href="<?php echo url_for('sales_index_pnp') ?>"><li class="no_sel"><span style="float: left;"><?php echo image_tag('Icons/ic_menu_products_parts.png') ?></span><span style="float: left; margin: -2px 0 0 0;">Materials</span><span style=" float: left; margin-top: -5px;">&amp; Products</span></li></a>
        <a href="<?php echo url_for('purchase_index') ?>"><li class="sel"><?php echo image_tag('Icons/ic_menu_purchase.png') ?>Purchase</li></a><!-- SELECTED TAB -->
        <a href="<?php echo url_for('stock_index') ?>"><li class="no_sel"><?php echo image_tag('Icons/ic_menu_stock.png') ?>Stock</li></a>
        <?php if($sf_user->isSuperAdmin()){ ?>
            <a href="<?php echo url_for('admin_index') ?>"><li class="no_sel"><?php echo image_tag('Icons/ic_menu_stock.png') ?>Admin</li></a>
        <?php } ?>
    </ul>
</div><!-- end navigation -->
<div id="page"><!-- The page -->
    <div id="par_header">
        <div id="bt_area"><!-- button area with all the buttons -->
            <div class="button"><!-- shopping list button -->
                <a href="<?php echo url_for('shoppingList_new') ?>">
                    <img src="<?php echo image_path('Buttons/bt_shoplist.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_shoplist_hov.png') ?>';" onmouseout="this.src='<?php  echo image_path('Buttons/bt_shoplist.png') ?>';" title="Create shopping list"/>
                </a>
            </div>
            <div class="button"><!-- make new purchase button -->
                <a href="<?php echo url_for('purchase_new') ?>">
                    <img src="<?php echo image_path('Buttons/bt_purchase.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_purchase_hov.png') ?>';" onmouseout="this.src='<?php  echo image_path('Buttons/bt_purchase.png') ?>';" title="Add new purchases"/>
                </a>
            </div>
            <div class="button"><!-- book purchases button -->
                <a href="<?php echo url_for('clearList_new') ?>">
                    <img src="<?php echo image_path('Buttons/bt_edit_purchase.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_edit_purchase_hov.png') ?>';" onmouseout="this.src='<?php  echo image_path('Buttons/bt_edit_purchase.png') ?>';" title="Book ordered purchases"/>
                </a>
            </div>
        </div><!-- end button area -->
        <div id="search"><!-- search -->
            <?php echo form_tag('purchase_filter') ?>
            <fieldset>
                <legend class="bold">Search Purchase</legend>
                <table>
                    <?php //echo $filterPurchase['name']->renderRow() ?>
                    <?php //echo $filterPurchase['material_id']->renderRow() ?>
                    <?php echo $filterPurchase['status']->renderRow() ?>
                    <tr><td><input type="submit" value="" name="submit_filter" class="bt_search" title="Search purchase"/></td></tr>
                </table>
                     <div id="del_list"><!-- Reset filter button -->
                        <a href="<?php echo url_for('purchase_index') ?>">
                            <img src="<?php echo image_path('Buttons/bt_cancel_small.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_cancel_small_hov.png') ?>';" onmouseout="this.src='<?php echo image_path('Buttons/bt_cancel_small.png') ?>';" width="55px" title="Back to complete purchase list"/>
                        </a>
                    </div>
                <span id="tooltip1"><a href=""><img src="<?php echo image_path('Buttons/bt_help.png') ?>" /><span>Select status to find purchase</span></a></span>
            </fieldset>   
        </div>
   </div>   
   <h2>Ordered Materials</h2>
    
   <?php include_partial('purchases', array('purchases' => $pagerPurchases->getResults()));
         include_partial('pagerMultiple', array('pager' => $pagerPurchases, 'url' => 'purchase_index', 'kind' => 'purchase', 'previousKind' => 'material', 'previousPager' => $pagerMaterials)); ?>

   <h2>Materials under minimum <td style="text-align: center;"><a href="<?php echo url_for('purchase/showMinimumList') ?>" target="_blank"><img src="<?php echo image_path('Buttons/bt_print_small.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_print_small_hov.png') ?>';"  onmouseout="this.src='<?php echo image_path('Buttons/bt_print_small.png') ?>';" title="Print"/></a></td></h2>
   <div id="materials_min" class="table_div">
            <table>
               <tr class="bold head">
                    <td>Material No.</td>
                    <td>Name</td>
                    <td>Type</td>
                    <td>Minimum</td>
                    <td>Stock</td>
                    <td>Unit</td>
                    <td width="35px"></td>
                    <td width="35px"></td>
                </tr>
                <?php foreach ($pagerMaterials as $i=>$material): ?>
                    <tr class="table_hov <?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
                        <td><?php echo $material->getPartNumber() ?></td>
                        <td><?php echo $material->getName() ?></td>
                        <td><?php echo $material->getType() ?></td>
                        <td><?php echo $material->getMinStock() ?></td>
                        <td><?php echo $material->getStock() ?></td>
                        <td><?php echo $material->getUnit() ?></td>
                        <td></td>
                        <td></td>
                    </tr>
                <?php endforeach; ?>
            </table>
   </div>
   <?php include_partial('pagerMultiple', array('pager' => $pagerMaterials, 'url' => 'purchase_index', 'kind' => 'material', 'previousKind' => 'purchase', 'previousPager' => $pagerPurchases)); ?>
</div>